<?php echo $header; ?>
<?php if ($error_warning) { ?>
<div class="warning"><?php echo $error_warning; ?></div>
<?php } ?>
<?php if ($success) { ?>
<div class="success"><?php echo $success; ?></div>
<?php } ?>
<div class="box">
  <div class="left"></div>
  <div class="right"></div>
  <div class="heading">
    <h1 style="background-image: url('view/image/category.png');"><?php echo $heading_title; ?></h1>
    <div class="buttons"><a onclick="location = '<?php echo $insert; ?>'" class="button"><span><?php echo $button_insert; ?></span></a><a onclick="$('form').submit();" class="button"><span><?php echo $button_delete; ?></span></a></div>
  </div>
  
  <div class="content">
  <form action="<?php echo $level_link; ?>" method="post" name="levelForm"> 
  	顯示最大目錄層數：
  	<select name="level" onchange="document.levelForm.submit();">
	    <option value="1" <?php if ($level == '1') {?>selected<?php }?>>1</option>
	    <option value="2" <?php if ($level == '2') {?>selected<?php }?>>2</option>
	    <option value="3" <?php if ($level == '3') {?>selected<?php }?>>3</option>
	    <option value="4" <?php if ($level == '4') {?>selected<?php }?>>4</option>
	    <option value="5" <?php if ($level == '5') {?>selected<?php }?>>5</option>
	    <option value="6" <?php if ($level == '6') {?>selected<?php }?>>6</option>
	    <option value="7" <?php if ($level == '7') {?>selected<?php }?>>7</option>
	    <option value="8" <?php if ($level == '8') {?>selected<?php }?>>8</option>
	    <option value="9" <?php if ($level == '9') {?>selected<?php }?>>9</option>
	    <option value="10" <?php if ($level == '10') {?>selected<?php }?>>10</option>
	    <option value="11" <?php if ($level == '11') {?>selected<?php }?>>11</option>
	    <option value="12" <?php if ($level == '12') {?>selected<?php }?>>12</option>
	    <option value="13" <?php if ($level == '13') {?>selected<?php }?>>13</option>
	    <option value="14" <?php if ($level == '14') {?>selected<?php }?>>14</option>
	    <option value="15" <?php if ($level == '15') {?>selected<?php }?>>15</option>
	    <option value="16" <?php if ($level == '16') {?>selected<?php }?>>16</option>
	    <option value="17" <?php if ($level == '17') {?>selected<?php }?>>17</option>
	    <option value="18" <?php if ($level == '18') {?>selected<?php }?>>18</option>
	    <option value="19" <?php if ($level == '19') {?>selected<?php }?>>19</option>
	    <option value="20" <?php if ($level == '20') {?>selected<?php }?>>20</option>
    </select>
    </form>
  	
    <form action="<?php echo $delete; ?>" method="post" enctype="multipart/form-data" id="form">
      <table class="list">
        <thead>
          <tr>
            <td width="20" style="text-align: center;"><?php echo $column_no;?></td>
            <td width="1" style="text-align: center;"><input type="checkbox" onclick="$('input[name*=\'selected\']').attr('checked', this.checked);" /></td>
            <td class="left"><?php if ($sort == 'menuname') { ?>
              <a href="<?php echo $sort_menuname; ?>" class="<?php echo strtolower($order); ?>"><?php echo $column_menuname; ?></a>
              <?php } else { ?>
              <a href="<?php echo $sort_menuname; ?>"><?php echo $column_menuname; ?></a>
              <?php } ?></td>
            <td class="left"><?php if ($sort == 'ordering') { ?>
              <a href="<?php echo $sort_ordering; ?>" class="<?php echo strtolower($order); ?>"><?php echo $column_ordering; ?></a>
              <?php } else { ?>
              <a href="<?php echo $sort_ordering; ?>"><?php echo $column_ordering; ?></a>
              <?php } ?></td>
            <td class="left"><?php if ($sort == 'menu_id') { ?>
              <a href="<?php echo $sort_menu_id; ?>" class="<?php echo strtolower($order); ?>"><?php echo $column_menu_id; ?></a>
              <?php } else { ?>
              <a href="<?php echo $sort_menu_id; ?>"><?php echo $column_menu_id; ?></a>
              <?php } ?></td>
            <td style="text-align: center;"><?php echo $column_content_count;?></td>
            <td class="right"><?php echo $column_action; ?></td>
          </tr>
        </thead>
        <tbody>
          <?php if ($menus) { $noCount = 1;?>
          <?php foreach ($menus as $menu) { ?>
          <tr>
            <td><?php echo $noCount++;?></td>
            <td style="text-align: center;"><?php if ($menu['selected']) { ?>
              <input type="checkbox" name="selected[]" value="<?php echo $menu['menu_id']; ?>" checked="checked" />
              <?php } else { ?>
              <input type="checkbox" name="selected[]" value="<?php echo $menu['menu_id']; ?>" />
              <?php } ?></td>
            <td class="left" style="color:#0b55c4;">
            	<?php 
            		for ($i = 0; $i < $menu['sublevel']; ++$i) {
            	?>
            	.&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
            	<?php }?>
            	<?php if ($menu['sublevel'] != 0) {?>
            	<sup>|_</sup>&nbsp;
            	<?php }?>
            	<?php echo $menu['menuname']; ?>
            </td>
            <td class="left"><?php echo $menu['ordering']; ?></td>
            <td class="left"><?php echo $menu['menu_id']; ?></td>
            <td class="left"><?php echo $menu['content_count']; ?></td>
            <td class="right">
            <?php foreach ($menu['action_view_content'] as $action_view_content) { ?>
              [ <a href="<?php echo $action_view_content['href']; ?>"><?php echo $action_view_content['text']; ?></a> ]
              <?php } ?>
            &nbsp;&nbsp;&nbsp;  
            <?php foreach ($menu['action'] as $action) { ?>
              [ <a href="<?php echo $action['href']; ?>"><?php echo $action['text']; ?></a> ]
              <?php } ?>
            </td>
          </tr>
          <?php } ?>
          <?php } else { ?>
          <tr>
            <td class="center" colspan="7"><?php echo $text_no_results; ?></td>
          </tr>
          <?php } ?>
        </tbody>
      </table>
    </form>
  </div>
</div>
<?php echo $footer; ?>